<?php

/**
 * 
 */
class Model_Mapper_Contato 
{
	/**
	 * 
	 * @var Zend_Config_Ini
	 */
	protected $_config;

	/**
	 * 
	 * @var App_Message
	 */
	protected $_message;
	
	/**
	 * 
	 * @access public
	 * @return void
	 */
	public function __construct ()
	{
		$this->_config 	= Zend_Registry::get( 'config' );
		$this->_message = new App_Message();
	}
	
	/**
	 *
	 * @access public
	 * @param array $data
	 * @return boolean
	 */
	public function send ( array $data )
	{
		try {
			
			$mail = new Zend_Mail( 'utf-8' );
			
			$mail->addTo( $this->_config->email->address, $this->_config->email->name );
			$mail->setSubject( 'Contato - ' . $this->_config->geral->title );
			$mail->setBodyHtml( $data['mensagem'] );
			$mail->setFrom( $data['email'], $data['nome'] );
			
			$mail->send();
			
			$this->_message->addMessage( $this->_config->messages->success, App_Message::SUCCESS );
			
			return true;
			
		} catch ( Exception $e ) {
			
			$this->_message->addMessage( $this->_config->messages->error, App_Message::ERROR );
			
			return false;
			
		}
	}
	
	/**
	 * 
	 * @return App_Message
	 */
	public function getMessage()
	{
		return $this->_message;
	}
}
